/************************************************************************

								Heroes IV
					  Copyright 2000, The 3DO Company

	------------------------------------------------------------------
  						       keyword_replacer.h

	$Header: /game/keyword_replacer.h $

	$NoKeywords: $

 ************************************************************************/

#ifndef KEYWORD_REPLACER_H_INCLUDED
#define KEYWORD_REPLACER_H_INCLUDED

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

// kill the 255+ character identifier warning.  Templates tend to exceed that easily.
#pragma warning( disable: 4786 )

#include <map>
#include <string>
#include "string_insensitive_compare.h"

enum  t_creature_type;
enum  t_material;
class t_material_array;

// ------------------------------------------------------------------------
// class which replaces keywords with text
// ------------------------------------------------------------------------
class t_keyword_replacer
{
public:
	t_keyword_replacer();
	virtual ~t_keyword_replacer();

	void		 add_keyword( std::string const& keyword, std::string const& text );
	void		 add_creature( int amount, t_creature_type creature,  bool approximate );
	void		 add_hero_to_creature_list( std::string const & hero_name );
	virtual void add_material( int amount, t_material material );
	void		 add_materials( t_material_array const& materials );
	void         add_to_list( std::string const& keyword, int count, std::string const& text );

	std::string operator()( std::string const& format_string ) const;
protected:
	typedef std::map<std::string, std::string, t_string_insensitive_less> t_map;

	std::string replace_word( std::string const& keyword ) const;

	int   m_material_count;
	int   m_creature_count;
	t_map m_map;
};

inline t_keyword_replacer::t_keyword_replacer()
{
	m_material_count = 0;
	m_creature_count = 0;
}

inline void t_keyword_replacer::add_keyword( std::string const& keyword, std::string const& text )
{
	m_map[keyword] = text;
}


#endif // KEYWORD_REPLACER_H_INCLUDED